package com.eastfair.venueservice.dao;

import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.eastfair.boot.mapper.SuperMapper;
import com.eastfair.venueservice.dto.ServiceBookingQuery;
import com.eastfair.venueservice.entity.ServiceBooking;

import com.eastfair.venueservice.entity.ServiceItem;
import com.eastfair.venueservice.entity.ServiceOrder;
import com.eastfair.venueservice.vo.ReportVenueSpaceNumVO;
import com.eastfair.venueservice.vo.ServiceBookingSimpleVO;
import com.eastfair.venueservice.vo.ServiceBookingVO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * Mapper 接口
 * 服务预订项
 * </p>
 *
 * @author linan
 * @date 2022-08-05
 */
@Repository
public interface ServiceBookingMapper extends SuperMapper<ServiceBooking> {

    /**
     * 查询服务预订
     * @param queryWrapper queryWrapper
     * @return List<ServiceBookingVO>
     */
    @InterceptorIgnore(tenantLine = "1")
    List<ServiceBookingVO> queryServiceBookingList(@Param(Constants.WRAPPER) QueryWrapper<ServiceBooking> queryWrapper);

    /**
     * 服务预订管理列表
     * @param serviceItemPage
     * @param queryWrapper
     * @return
     */
    Page<ServiceBookingVO> queryServiceBookingManage(IPage<ServiceItem> serviceItemPage, @Param(Constants.WRAPPER) QueryWrapper<ServiceBooking> queryWrapper);

    /**
     * 主场一键报馆的全部服务
     * @param page
     * @param wrapper
     * @return
     */
    Page<ServiceBookingVO> queryServiceBookingOfHome(Page<ServiceBookingQuery> page, @Param(Constants.WRAPPER) QueryWrapper<ServiceBooking> wrapper);

    /**
     * 查询报馆服务数量
     * @param reportVenueSpaceNumbers
     * @return
     */
    List<Map<String, Object>> queryBookingServiceNum(@Param("reportVenueSpaceNumbers") List<String> reportVenueSpaceNumbers);

    /**
     * 服务预订列表（主运）
     * @param queryWrapper
     * @return
     */
    List<ServiceBookingVO> queryServiceBookingListOfOrder(@Param(Constants.WRAPPER) QueryWrapper<ServiceBooking> queryWrapper);

    /**
     * 通过订单编号查询服务
     * @param orderNumber orderNumber
     * @return List<ServiceBookingVO>
     */
    List<ServiceBookingVO> queryServiceBookingListByOrderNumber(@Param("orderNumbers")List<String> orderNumbers);

    /**
     * 统计展厅报馆服务数量
     * @param queryWrapper
     * @return
     */
    List<ServiceBookingVO> queryReportServiceCount(@Param(Constants.WRAPPER) QueryWrapper<ServiceBooking> queryWrapper);

    /**
     * 通过展会查询资金情况
     * @param exhibitionManageId
     * @return
     */
    List<ServiceBookingSimpleVO> queryExhibitionFinance(@Param("exhibitionManageId") Long exhibitionManageId);

    /**
     * 展位报馆统计
     * @param exhibitionManageId
     * @return
     */
    List<ReportVenueSpaceNumVO> queryReportSpaceNum(@Param("exhibitionManageId") Long exhibitionManageId);

    /**
     * 服务库存预警
     * @return
     */
    List<ServiceBookingSimpleVO> queryWarningRanking();

    /**
     * 通过预订id查询订单
     * @param ids
     * @return
     */
    List<ServiceOrder> selectOrderNumbers(@Param("ids") List<Long> ids);

    /**
     * 查询展位下预定的服务列表.
     *
     * @param queryWrapper the query wrapper
     * @return the list
     */
    List<ServiceBookingVO> listServiceBookingBySiteName(@Param(Constants.WRAPPER) QueryWrapper<ServiceBooking> queryWrapper);

    /**
     * 服务分类统计费用.
     *
     * @param queryWrapper the query wrapper
     * @return the list
     */
    List<Map<String, Object>> sumServiceCategoryFinance( @Param(Constants.WRAPPER) QueryWrapper<ServiceBooking> queryWrapper);

    /**
     * 查询所有预定的各项服务总金额
     * @param ids
     * @param exhibitionManageId
     * @return
     */
    List<ServiceBookingVO> queryServiceItemAmount(@Param("ids") List<Long> ids, @Param("exhibitionManageId") Long exhibitionManageId);

    /**
     * 统计服务预定排行.
     *
     * @param queryWrapper the query wrapper
     * @return the list
     */
    List<ServiceBookingVO> countHomeServiceBookingNum(@Param(Constants.WRAPPER) QueryWrapper<ServiceBooking> queryWrapper);

    /**
     * 主办已预定的服务统计
     * @param serviceBookingQuery serviceBookingQuery
     * @return List<ServiceBookingVO>
     */
    List<ServiceBookingVO> querySponsorServiceBookingStat(@Param(Constants.WRAPPER) QueryWrapper<ServiceBooking> serviceBookingQuery);
}
